const instance = axios.create({
    // baseURL: process.env.BASE_API, // node环境的不同，对应不同的baseURL
    // withCredentials: true // 允许携带cookie  
});
instance.interceptors.response.use(res => res.data);

// const baseUrl = "http://localhost:4000"
const baseUrl = "http://www.yemengshen.cn"
// const baseUrl = "http://www.yemengs.cn"

export default function(obj, options) {
    let { method, url, data } = obj
    url = baseUrl + url
    if (method === "get") {
        return instance.get(url, {
            params: data
        })
    } else {
        if (options) {
            return instance.post(url, data)
        } else {
            return instance.post(url, data, options)
        }
    }
}